(function(fields){
	var listpanel = [];
	fields.sort(function(a,b){
		return a.index>b.index;
	});

	
	for(f in fields){
		if(fields[f].type=="list"){
			//log(fields[f]);
			var classdat = Get("/clazz/name/"+fields[f].clazz).obj;
			var columns  = [];
			var itemsfields = classdat.fields;
			columns.push({
				xtype: 'actioncolumn',
		        width: 30,
		        sortable: false,
		        menuDisabled: true,
		        items: [{
		        	icon: "lib/ext/shared/icons/fam/delete.gif",
		            tooltip: 'Delete',
		            scope: this,
		            handler:function(grid, rowIndex, colIndex, actionItem, event, record, row){
		            	grid.store.remove(record);
		            }
		        }]
			}); 
			for(i in itemsfields){
				if(itemsfields[i].type=="obj"){
					columns.push({
						flex:1,
						header		: itemsfields[i].text,
						dataIndex	: itemsfields[i].name,
						editor: {
				            allowBlank	: false ,
				         	trigger1Cls	: Ext.baseCSSPrefix  +  'form-search-trigger',
				         	xtype		: "triggerfield"
				        }
					});
				}else{
					columns.push({
						flex:1,
						header		: itemsfields[i].text,
						dataIndex	: itemsfields[i].name,
						editor: {
				             allowBlank: false 
				        }
					});
				}
				
			}
			listpanel.push({
				title:fields[f].text,
				columns:columns,
				xtype:"grid",
				store:{
					data:[],
				    proxy: {
				        type: 'memory',
				        reader: {
				            type: 'json' 
				        }
				    }	
				}
			});
		}
	}
	return listpanel;
})